<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/tabs.jsp"%>
<%@ taglib uri="http://www.myce.net.cn/ce-tag" prefix="ce"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link href="${ctx}/styles/listTable.css" rel="stylesheet" type="text/css">
<link href="${ctx}/styles/grid.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="${ctx}/scripts/div/css/window.css" />
<link href="${ctx}/styles/aux_window.css" rel="stylesheet" type="text/css">
<link href="${ctx}/styles/public.css" rel="stylesheet" type="text/css">
<link href="${ctx}/styles/worktable.css" rel="stylesheet" type="text/css" />
<script language="JavaScript"  src="${ctx}/scripts/common/prototype.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/public.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/global.js"></script>
<script language="JavaScript"  src="${ctx}/scripts/show.js"></script>
<script language="JavaScript"  src="${ctx}/scripts/div/common.js"></script>
<script language="JavaScript"  src="${ctx}/scripts/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script>
	var id = null;
	var type = null;
	function openReason(type)
	{
	    id = null;
		var url = "${ctx}/house_partnershipAction.do?method=initReasonAdd&type="+type;
		if(type == "copyMeter")
		{
			top.windowOpen(url,"openCopyMeter","${key.copyMeterAdd}",310,450);
		}
		else if(type == "checkHouse")
		{
			top.windowOpen(url,"checkHouse","${key.checkHouseAdd}",310,450);
		}
		else if(type == "goodsTransfer")
		{
			top.windowOpen(url,"goodsTransfer","${key.goodsTransferAdd}",310,450);
		}
	}

	function openGoodsRecord()
	{
		id = null;
		var url = "${ctx}/house_partnershipAction.do?method=initGoodsRecordAdd";
		top.windowOpen(url,"goodsRecord","${key.goodsRecordAdd}",310,450);
	}

	function editReason()
	{
		if(id == null)
		{
			ErrorAlert("${key.tipsByModify}");
			return false;
		}
		else
		{
			var url = "${ctx}/house_partnershipAction.do?method=initReasonEdit&type="+type+"&id="+id;
			if(type == "copyMeter")
			{
				top.windowOpen(url,"openCopyMeter","${key.copyMeterEdit}",310,450);
			}
			else if(type == "checkHouse")
			{
				top.windowOpen(url,"checkHouse","${key.checkHouseEdit}",310,450);
			}
			else if(type == "goodsTransfer")
			{
				top.windowOpen(url,"goodsTransfer","${key.goodsTransferEdit}",310,450);
			}
		}

	}

	function editGoodsRecord()
	{
		if(id == null)
		{
			ErrorAlert("${key.tipsByModify}");
			return false;
		}
		var url = "${ctx}/house_partnershipAction.do?method=initGoodsRecordEdit&id="+id;
		top.windowOpen(url,"goodsRecord","${key.goodsRecordEdit}",310,450);
	}

	function showDeleteReason()
	{
		if(id == null)
		{
			ErrorAlert("${key.tipsByDelete}");
		}
		else
		{
		    var url = "${ctx}/house_partnershipAction.do?method=checkReferenceReason";
		    var str = "types="+type+"&id="+id;
			new Ajax.Request(url,{method: 'post' ,parameters:str ,onSuccess : function(response){
			    ajaxSubmitException(response.responseText);
				if(response.responseText == 'true'){
				    id = null;
					Alert("${key.deleteReference}");
				}
				else{
				  AlarmConfirm('${key.tipsByDeleteConfirm}',"main","deleteReason");
				}
			}});

		}
	}

	function deleteReason()
	{
		var str = "types="+type+"&id="+id;
		var myAjax = new Ajax.Request("${ctx}/house_partnershipAction.do?method=deleteReason",
                   {method: 'post', parameters: str, onComplete: function(response) {
                     ajaxSubmitException(response.responseText);
	                 if('true' == response.responseText)
					    freshListWithCondition(type);
	               	}}
                   );
         id = null;
	}

	function showDeleteGoodsRecord()
	{
		if(id == null)
		{
			ErrorAlert("${key.tipsByDelete}");
			return false;
		}
		else
		{
			var url = "${ctx}/house_partnershipAction.do?method=checkReferenceReason";
		    var str = "id="+id;
			new Ajax.Request(url,{method: 'post' ,parameters:str ,onSuccess : function(response){
			    ajaxSubmitException(response.responseText);
				if(response.responseText == 'true'){
				    id = null;
					Alert("${key.deleteReference}");
				}
				else{
				  AlarmConfirm('${key.tipsByDeleteConfirm}',"main","deleteGoodsRecord");
				}
			}});
		}
	}

	function deleteGoodsRecord()
	{
		var str = "id="+id;
		var myAjax = new Ajax.Request("${ctx}/house_partnershipAction.do?method=deleteGoodsRecord",
                   {method: 'post', parameters: str, onComplete: function(response) {
	                 if('true' == response.responseText.strip()){
						freshListWithCondition(type);
	               	}}}
                   );
        id = null;
	}

	function setReason(reasonId,reasonType)
	{
		id = reasonId;
		type = reasonType;
	}


	function setPostion()
	{
		id = null;
		type = null;
	}

	function submitSearch(formId)
	{
	    id = null;
		if(formId == "reasonForm")
			$(formId).action = "${ctx}/house_partnershipAction.do?method=findAllReasonBySearch";
		else
			$(formId).action = "${ctx}/house_partnershipAction.do?method=findAllGoodsRecordBySearch";
		$(formId).submit();

	}

	function freshListWithCondition(t)
	{
		id = null;
		var formId = null;
		var obj = findFrame('connTabPanel');
	    var pageNO = obj.getPageNO();
	    if(t == "goodsRecord")
	    {
	    	formId = 'goodsForm';
	    	$(formId).action = "${ctx}/house_partnershipAction.do?method=findAllGoodsRecordBySearch&ec_p="+pageNO;
	    }
	    else
	    {
			formId = "reasonForm";
			$(formId).action = "${ctx}/house_partnershipAction.do?method=findAllReasonBySearch&ec_p="+pageNO;
		}
		$(formId).submit();

	}

	function freshListWithoutCondition(t)
	{
	    id = null;
		var formId = null;
	    if(t == "goodsRecord")
	    	formId = 'goodsForm';
	    else
			formId = "reasonForm";
		$(formId).reset();
		submitSearch(formId);
	}
</script>

</head>
<body>
<div class="pageNav_bg">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td id="pageNav_leftimg"><img src="${ctx}/images/ico_fc_tihuo.gif" width="46" height="47"/></td>
      <td id="navWord"><span class="page_title">${key.goOut}</span></td>
      <td class="pageNav_right"><a href="javascript:showFull_in();"><img id="full_image"  src="${ctx}/images/ico_fullscreen.gif" border="0"/></a></td>
    </tr>
  </table>
</div>

<div id="reasonTop" >
	<table width="100%" border="0" cellpadding="0" cellspacing="0" id="search01" class="bg_search">
			<form name="reasonForm" method="post" action="${ctx}/house_partnershipAction.do?method=findAllReasonBySearch" target="connTabPanel">
            <tr>
              <td >

                  <table border="0" cellpadding="0" cellspacing="1">
                  <tr>
                    <td class="td_search">${key.exceptionType}：</td>
                    <td class="td_search">
                    	<mypms:Sysrefcode  name="types" showTip="false" code="CS_REASON_DEF_REASON_TYPE" style="width:110px" >
            			</mypms:Sysrefcode>
                    </td>
                    <td class="td_search">${key.exceptionName}：</td>
                    <td class="td_search"><input id="reasonName" name="name" type="text" class="inputtext" size="16" /></td>

                    <td class="td_search"><table border="0" cellpadding="0" cellspacing="0" >
                        <tr>
                          <td class="buttonOffLeft" id="btn1_11"></td>
                          <td class="buttonOffMiddle" id="btn1_12" onclick="submitSearch('reasonForm')" onblur="btn_change(1)" onMouseOver="btn_change_over(1)" onMouseOut="btn_change_out(1)"><img src="${ctx}/images/ico_searchico.gif" alt="" border="0" align="absmiddle" />
                            ${key.search}</td>
                          <td class="buttonOffRight" id="btn1_13"></td>
                        </tr>
                    </table></td>

                  </tr>
              </table>

              </td>
            </tr>
            </form>
          </table>

</div>

<div id="choiceReason" class="quick_menu2" style="display:none;">
  <table width="100%" border="0" cellpadding="1" cellspacing="0" class="grid_quickMenu_bg" onMouseOver="showmy2menu('choiceReason')" onMouseOut="hidden2menu('choiceReason')">
       <tr>
      <td>
	  <table width="100%" border="0" cellpadding="2" cellspacing="0">
	    <tr>
         <td class="quickMenu_toolbarico"><a href="#" onclick="openReason('copyMeter');" onFocus="this.blur()"><img src="${ctx}/images/ico_newfile.gif" alt="${key.copyMeterAdd}" border="0" align="absbottom"/>${key.copyMeterAdd}</a></td>
          </tr>
        <tr>
         <td class="quickMenu_toolbarico"><a href="#" onFocus="this.blur()" onclick="openReason('checkHouse');"><img src="${ctx}/images/ico_newfile.gif" alt="${key.checkHouse}" border="0" align="absbottom"/>${key.checkHouse}</a></td>
          </tr>
		  <tr>
         <td class="quickMenu_toolbarico"><a href="#" onFocus="this.blur()" onclick="openReason('goodsTransfer');"><img src="${ctx}/images/ico_newfile.gif" alt="${key.goodsTransfer}" border="0" align="absbottom"/>${key.goodsTransfer}</a></td>
          </tr>
      </table></td>
    </tr>
  </table>
</div>

<div id="reasonRight" style="display:none;" >
	<table border="0" cellpadding="0" cellspacing="0">
	<tr>

		  <td class="quickMenu_toolbarico"><a href="#" onClick="showmenulist('choiceReason',this)" onMouseOut="hidden2menu('choiceReason')"><img src="${ctx}/images/customer_owners.gif" alt="${key.add}" border="0" align="absbottom"/></a></td>
		  <td class="quickMenu_toolbarico"><a href="#" onclick="editReason();" onFocus="this.blur()"><img src="${ctx}/images/ico_amend.gif" border="0" align="absbottom" alt="${key.modify}"  /></a></td>
		  <td class="quickMenu_toolbarico"><a href="#" onClick="showDeleteReason();" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="${key.delete}" width="16" height="16" border="0" align="absbottom">
            </a></td>
        </tr>
  </table>

</div>



<div id="goodsTransferTop" style="display:none;">
	<table width="100%" border="0" cellpadding="0" cellspacing="0"   id="search02"  class="bg_search" >
	<form name="goodsForm" method="post" action="${ctx}/house_partnershipAction.do?method=findAllGoodsRecordBySearch" target="connTabPanel">
            <tr>
              <td>

                <table border="0" cellpadding="0" cellspacing="1">
                <tr>
                  <td class="grid align_left">${key.goods}：</td>
                  <td class="td_search align_left">
                    <input id="goodsName" name="name" type="text" class="inputtext" size="16" />
                  </td>
                  <td class="td_search"><table border="0" cellpadding="0" cellspacing="0" >
                      <tr>
                        <td class="buttonOffLeft" id="btn1_11"></td>
                        <td class="buttonOffMiddle" id="btn1_12" onclick="submitSearch('goodsForm')" onblur="btn_change(1)" onMouseOver="btn_change_over(1)" onMouseOut="btn_change_out(1)"><img src="${ctx}/images/ico_searchico.gif" alt="" border="0" align="absmiddle" />
                          ${key.search}</td>
                        <td class="buttonOffRight" id="btn1_13"></td>
                      </tr>
                  </table></td>
                </tr>
              </table>

              </td>
            </tr> </form>
          </table>
</div>
<div id="goodsTransferRight" style="display:none;">
	<table  border="0" cellpadding="0" cellspacing="0">
       <tr>
		  <td class="quickMenu_toolbarico"><a href="#" onclick="openGoodsRecord();"><img src="${ctx}/images/ico_newfile.gif" border="0" align="absbottom" alt="${key.add}"/> </a></td>
		  <td class="quickMenu_toolbarico"><a href="#"  onClick="editGoodsRecord();" onFocus="this.blur()"><img src="${ctx}/images/ico_amend.gif" border="0" align="absbottom" alt="${key.modify}"/> </a></td>
		  <td class="quickMenu_toolbarico"><a href="#" onClick="showDeleteGoodsRecord();" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="${key.delete}" width="16" height="16" border="0" align="absbottom"> </a></td>
        </tr>
         </table>
</div>

<ce:tabPanel panelId="con_tabPanel"
            iframeId="connTabPanel"
            hasTop="false"
            defaultHeight="400px">

  <ce:tab tabId="reasonId"
    caption="${key.exception}"
    topDiv ="reasonTop"
    rightDiv = "reasonRight"
    baseUrl="${ctx}/house_partnershipAction.do?method=initReasonList"
    beforeFunction = "setPostion();"
    />

  <ce:tab tabId="goodsRecordId"
    caption="${key.goodsRecord}"
    topDiv ="goodsTransferTop"
	rightDiv = "goodsTransferRight"
    baseUrl="${ctx}/house_partnershipAction.do?method=initGoodsRecordList"
    beforeFunction = "setPostion();"
    />

</ce:tabPanel>

</body>
</html>
